home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr01 / halcn305.zip / TESTFIND.PAS < prev    next >
Pascal/Delphi Source File  |  1993-07-27  |  2KB  |  77 lines

  1. program TestFind;
  2. {------------------------------------------------------------------------------
  3.                           DBase File Index Find
  4.  
  5.        TESTFIND.PAS Copyright (c)  Richard F. Griffin
  6.  
  7.        24 July 1993
  8.  
  9.        102 Molded Stone Pl
  10.        Warner Robins, GA  31088
  11.  
  12.        -------------------------------------------------------------
  13.        This program demonstrates how dBase files may use the Find call.
  14.  
  15. -------------------------------------------------------------------------------}
  16.  
  17. uses
  18.    GSOBShel,
  19.    {$IFDEF WINDOWS}
  20.       WinCRT,
  21.       WinDOS;
  22.    {$ELSE}
  23.       CRT,
  24.       DOS;
  25.    {$ENDIF}
  26.  
  27.  
  28. var
  29.    NameIn  : string;
  30.  
  31. begin
  32.    ClrScr;
  33.    if not FileExist('GSDMO_01.DBF') then
  34.    begin
  35.       writeln('File GSDMO_01.DBF not found.  Run GSDMO_01 to create.');
  36.       halt;
  37.    end;
  38.                        {The 'Real' example starts here}
  39.  
  40.    Select(1);
  41.    Use('GSDMO_01');
  42.  
  43.                 {use IndexOn to create the index}
  44.                 {This is only needed the first time through}
  45.                 {It can be commented out for future runs}
  46.                 {and Index('TESTFIND') used to open the index}
  47.  
  48.    IndexOn('TESTFIND','LASTNAME+FIRSTNAME');
  49.  
  50. {   Index('TESTFIND');}
  51.  
  52.    GoTop;
  53.    while not dEOF do
  54.    begin
  55.       writeln(FieldGet('LASTNAME'),' ',
  56.               FieldGet('FIRSTNAME'),'  ',
  57.               FieldGet('BIRTHDATE'));
  58.       Skip(1);
  59.    end;
  60.    namein := '';
  61.    repeat
  62.       write('Enter Name to Find (Case Sensitive): ');
  63.       readln(namein);
  64.       if namein <> '' then
  65.       begin
  66.          Find(namein);
  67.          if Found then
  68.             writeln('Record Found - ',
  69.                     FieldGet('LASTNAME'),' ',
  70.                     FieldGet('FIRSTNAME'))
  71.          else Writeln('No Match!!');
  72.       end;
  73.    until namein = '';
  74.    CloseDataBases;
  75.    write('Press any Key to continue:');
  76. end.
  77.